package com.feifan.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.feifan.api.annotation.LogType;
import com.feifan.api.annotation.SystemLog;
import com.feifan.api.annotation.UserLoginToken;
import com.feifan.api.model.UmsUserView;
import com.feifan.api.service.IUmsUserViewService;
import com.feifan.common.CommonPage;
import com.feifan.common.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @program: FinalProject
 * @author: Xiaofan
 * @createTime: 2021-08-13 09:23
 * @description: Functions of this class is
 **/
@RestController
@CrossOrigin
@Api(tags = "UmsUserViewController",description = "UserView统计数据管理")
@RequestMapping(value = "/uv")
public class UmsUserViewController {

    @Reference(
            version = "1.0.0",
            interfaceName = "com.feifan.api.service.IUmsUserViewService",
            interfaceClass = IUmsUserViewService.class,
            timeout = 170000
    )
    private IUmsUserViewService service;

    @ApiOperation(value = "UserView统计类型管理")
    @GetMapping(value = "/type")
    @UserLoginToken
    @ResponseBody
    public CommonResult<CommonPage<UmsUserView>> getUserViewType(){
        return CommonResult.success(service.listTypeUV());
    }


    @ApiOperation(value = "UserView统计数据管理")
    @GetMapping(value = "/list")
    @UserLoginToken
    @ResponseBody
    @SystemLog(description = "UserView统计数据管理",type = LogType.UMS_USER_VIEW_TYPE_LIST)
    public CommonResult<CommonPage<UmsUserView>> getUserViewList(@RequestParam(value = "start")String start,
                                                                 @RequestParam(value = "end")String end,
                                                                 @RequestParam(value = "type")String type){
        return CommonResult.success(service.listUV(start,end,type));
    }
}